package com.naiterui.ehp.bs.patient.controller.inner;

import com.naiterui.common.repository.page.PageVO;
import com.naiterui.ehp.bp.bo.consult.ConsultSessionListBo;
import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.patient.exception.ExceptionCodes;
import com.naiterui.ehp.bs.patient.service.IConsultCommentService;
import com.naiterui.ehp.bs.patient.service.IConsultSessionService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 会话相关内部接口
 * @Author gongbaoqiang
 * @Date 2020/7/3 7:14 PM
 */
@Api(tags = {SwaggerTag.PATIENT + SwaggerTag.INNER_API + SwaggerTag.CONSULT})
@Slf4j
@RestController
@RequestMapping("ap/inner/consult")
public class ApInnerConsultController {

    @Autowired
    private IConsultCommentService consultCommentService;

    @Autowired
    private IConsultSessionService consultSessionService;

    /**
     * 会话评价回复
     *
     * @return
     */
    @PostMapping("/comment/reply")
    public ResponseVO<Void> consultCommentReply(Long patientId, String msg) throws BusinessException {
        log.info("医生针对会话评价回复，参数信息 patientId={}, msg={}", patientId, msg);
        consultCommentService.reply(patientId, msg);
        return PublicService.returnResponseVO(ExceptionCodes.SUCCESS);
    }


    /**
     * 图文咨询列表
     *
     * @param patientId
     * @param page
     * @param num
     * @return
     * @throws BusinessException
     */
    @GetMapping("consultSessionList")
    public ResponseVO<PageVO<ConsultSessionListBo>> consultSessionList(Long patientId, int page, int num) throws BusinessException {
        log.info("获取图文咨询列表 请求参数：patientId = {}, page = {}, num = {}", patientId, page, num);
        PageVO<ConsultSessionListBo> patientCasePageVO = consultSessionService.consultSessionList(patientId, page, num);
        return PublicService.returnResponseVO(ExceptionCodes.SUCCESS, patientCasePageVO);
    }
}
